package entity;

/**
 * @Author: wanqian
 * @Date: 2021/2/25 9:57
 */
public class StringDemo {

    public static void main(String[] args) {
        String s1 = new String("a");
        System.out.println(s1 == "a");

        String s2 = "a";
        String s3 = s1.intern();
        System.out.println(s2 == s3);

        String s4 = new String("1") + new String("2");
        s4.intern();
        String s5 = "12";
        System.out.println(s4 == s5);
    }

    public static void test1() {
        //常量相加
        String st = "a" + "b";
    }

    public static void test2() {
        //常量与引用变量相加
        String sta = "a";
        String string = sta + "b";
    }

    public static void test3() {
        final String sta = "a";
        String string = sta + "b";
    }
}
